/*
 * InformationException.h
 *
 *  Created on: 7 nov. 2008
 *      Author: Administrateur
 */

#ifndef INFORMATIONEXCEPTION_H_
#define INFORMATIONEXCEPTION_H_
#include<exception>
#include<iostream>
#include<sstream>

using namespace std;

class InformationException : public std::exception {
public:

	virtual ~InformationException() throw() {}

	InformationException(std::string const& s) {
		errorMsg << s;
	}

	InformationException(InformationException const& src) {
		errorMsg << src.errorMsg.str();
	}

	template<typename T> InformationException& add(T const& val) {
		errorMsg << val;
		return *this;
	}

	template<typename T> InformationException& operator<<(T const& val) {
		errorMsg << val;
		return *this;
	}

	virtual const char* what () const throw () {	// Le dernier throw indique au compilateur qu'elle ne lancera JAMAIS d'exception
		return errorMsg.str().c_str();
	}

public:
	ostringstream errorMsg;
};

#endif /* INFORMATIONEXCEPTION_H_ */
